{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>编辑</h5>
                </div>
                <div class="ibox-content layui-form">
                    <div class="layui-row layui-col-space10 layui-form-item ">

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">标题/名字：</label>
                            <div class="layui-input-block">
                                <input type="text" name="pb_title" value="{$info.pb_title}" placeholder="标题/名字" class="layui-input ">
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8 form-group">
                            <label class="layui-form-label">类型：</label>
                            <div class="layui-input-block">
                                <select name="pb_type" lay-filter="role" disabled>
                                    <option value="1" {if $info.pb_type==1}selected{/if}>H5</option>
                                    <option value="2" {if $info.pb_type==2}selected{/if}>文档</option>
                                </select>
                            </div>
                        </div>
                        {if $info.pb_type==1}
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">缩略图：</label>
                            <input type="hidden" name="pb_thumb" id="lay-img" lay-verify="image" value="{$info.pb_thumb}">
                            <div class="layui-input-block">
                                <div id="lay-upload">上传图片</div>
                                <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                                    预览图：
                                    <div class="layui-upload-list" id="lay-list">
                                        <img class="layui-append-img" src="{$info.pb_thumb}" onerror="this.src='/static/admin/images/no_img.jpg'">
                                    </div>
                                </blockquote>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8" id="pb_desc">
                            <label class="layui-form-label">中间描述：</label>
                            <div class="layui-input-block">
                                <input type="text" name="pb_desc" value="{$info.pb_desc}" placeholder="中间描述" class="layui-input ">
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8" id="pb_bottom">
                            <label class="layui-form-label">底部描述：</label>
                            <div class="layui-input-block">
                                <input type="text" name="pb_bottom" value="{$info.pb_bottom}" placeholder="底部描述" class="layui-input ">
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8" id="pb_url">
                            <label class="layui-form-label">外链地址：</label>
                            <div class="layui-input-block">
                                <input type="text" name="pb_url" value="{$info.pb_url}" placeholder="外链地址" class="layui-input ">
                            </div>
                        </div>
                        {else /}
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">文档：</label>
                            <input type="hidden" name="pb_url2" id="lay-img2" lay-verify="image" value="{$info.pb_url}">
                            <div class="layui-input-block">
                                <div id="lay-upload2">上传文档</div>
                                <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                                    文件地址：
                                    <div class="layui-upload-list" id="lay-list2">
                                        {$info.pb_url}
                                    </div>
                                </blockquote>
                            </div>
                        </div>
                        {/if}
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">排序：</label>
                            <div class="layui-input-block">
                                <input type="text" name="pb_sort" value="{$info.pb_sort}" lay-verify="required" placeholder="排序" class="layui-input" oninput="value=value.replace(/[^\d]/g,'')">
                            </div>
                        </div>
                        <input type="hidden" value="{$info.pb_id}" name="pb_id">
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit="" lay-filter="component-form-element">保存
                                </button>
                                <button class="layui-btn layui-btn-primary" onclick="wk.layer_close('close')">关闭</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    wk.uploadImg({size:5,type:'png,jpg,jpeg',url:"{:url('Upload/upload')}",domain:""});
    wk.uploadImg({size:100,num:2,type:'pdf,PDF,doc,docx,DOC,DOCX',url:"{:url('Upload/upload')}",video:2}); //文档
    layui.use(['form','upload','layedit'], function() {
        var form = layui.form;
        form.on('submit(component-form-element)', function (data) {
            $('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
            $.ajax({
                url:"{:url('fileEdit')}",
                type:'post',
                dataType:'json',
                data:data.field,
                success:function(res){
                    if (res.code == 200) {
                        layer.msg(res.msg,{icon:1,time:1500,shade:0.1},function(index){
                            wk.layer_close();
                        })
                    } else {
                        wk.error(res.msg,'','$(".layui-btn").removeClass(\'layui-disabled\').removeAttr(\'disabled\');');
                    }
                }
            })
        });
    });
</script>

</body>
</html>
